package com.kaifamiao.wendao.listener;

import com.kaifamiao.wendao.utils.DataSourceFactory;
import com.kaifamiao.wendao.utils.SnowflakeIdGenerator;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;


@WebListener
public class NumberListener implements HttpSessionListener {

    private int count=0;

@Override
 public void sessionCreated(HttpSessionEvent event){
    count++;
    ServletContext context=event.getSession().getServletContext();
    context.setAttribute("count",count);
}

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        count--;
        ServletContext context=se.getSession().getServletContext();
        context.setAttribute("count",count);
    }
}
